import ddddocr
import cv2

# 识别基础数字字母验证码  beta = True 启用新版模型
ocr = ddddocr.DdddOcr()
with open("imgs/x5tb.png", 'rb') as f:
# with open("imgs/436102.png", 'rb') as f:
    bytes = f.read()
    result = ocr.classification(bytes)
    print(result)


# 目标检测  返回检测区域
# det = ddddocr.DdddOcr(det=True)
# with open("./imgs/汉字.png", "rb") as f:
# 	content = f.read()
# 	bboxes = det.detection(content)
# 	print(bboxes)
#
# 	im = cv2.imread("./imgs/坑位.png")
# 	for bbox in bboxes:
# 		x1, y1, x2, y2 = bbox
# 		im = cv2.rectangle(im, (x1, y1), (x2, y2), color=(0, 0, 255), thickness=2)
#
# 	cv2.imwrite("./imgs/坑位.png", im)



# 滑块检测算法1   找坑位

# det = ddddocr.DdddOcr(det=False, ocr=False)
#
# with open('./imgs/坑位.png', 'rb') as f:
# 	target_bytes = f.read()
#
# with open('./imgs/坑位.png', 'rb') as f:
# 	background_bytes = f.read()
#
# res = det.slide_match(target_bytes, background_bytes)
#
# print(res)



# slide = ddddocr.DdddOcr(det=False, ocr=False)
#
# with open('./codes/bg.jpg', 'rb') as f:
# 	target_bytes = f.read()
#
# with open('./codes/full.jpg', 'rb') as f:
# 	background_bytes = f.read()
#
# img = cv2.imread("bg.jpg")
#
# res = slide.slide_comparison(target_bytes, background_bytes)
#
# print(res)